package mh.entity;

/**
 * Used to specify the registration point of an <code>Entity</code>
 * 
 * @author Gianmarco Laggia
 * @author Alberto D'Este
 * 
 */
public enum EnumPosition{
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; X &nbsp;&nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	TOP(1),
	/**
	 * <code>
	 * +---------+<br>
	 * |X &nbsp;&nbsp; &nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	TOP_LEFT(2),
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; &nbsp; &nbsp; X|<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	TOP_RIGHT(3),
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; X &nbsp;&nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	BOTTOM(4),
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * |X &nbsp;&nbsp; &nbsp; &nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	BOTTOM_LEFT(5),
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp; &nbsp; X|<br>
	 * +---------+<br>
	 * </code>
	 */
	BOTTOM_RIGHT(6),
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * |X &nbsp;&nbsp; &nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	LEFT(7),
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp; &nbsp; X|<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	RIGHT(8),
	/**
	 * <code>
	 * +---------+<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * | &nbsp;&nbsp; X &nbsp;&nbsp; |<br>
	 * | &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; |<br>
	 * +---------+<br>
	 * </code>
	 */
	CENTER(9);

	private int	stateIndex;

	private EnumPosition(int stateIndex) {
		this.stateIndex = stateIndex;
	}

	/**
	 * @param stateIndex
	 * @return The EnumState that corresponds to the given index
	 */
	public static EnumPosition getPosition(int stateIndex) {
		for (EnumPosition l : EnumPosition.values()) {
			if (l.stateIndex == stateIndex) {
				return l;
			}
		}
		throw new IllegalArgumentException("State not valid.");
	}

}
